<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %> 
<%@ taglib uri="/WEB-INF/tld/ui.tld" prefix="ui" %> 
<%String path = request.getContextPath() ;%>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<jsp:include page="../../import.jsp" flush="true" />
</head>
<body class="iframeBody">
<div class="Wrapper">
<div>
<div id="pageInTab" class="pageInTab">
	<div tabid="tabA" lselected="true">
		<div class="searchArea">
			<!-- 搜索表单开始 -->
			<form id="searchBar">
				<div class="fieldset1 clearFix">
					<div class="FXBR">
						 <div class="fieldBox">
							<div class="label">交接单名称</div>
							<div class="field">
								<input type="text" id="listName" name="listName" class="ui-textbox" ligerui="width: 160"  >
							</div>
						</div>
						<div class="fieldBox">
							<div class="label">事业部</div>
							<div class="field">
			                     <select name="buOrgCd" id="buOrgCd"  ligerui="width: 160">
			                    	<option value="">请选择</option>
			                         <c:forEach items="${buOrgCdList }" var="item">
			                     		<option value="${item.key }">${item.value }</option>
			                        </c:forEach>
			                    </select>
							</div>
						</div>
						<div class="fieldBox">
							<div class="label">结清类型</div>
							<div class="field">
								 <input id="settleTypeList" name="settleTypeList"  type="text" class="ui-textbox" data-value=" " placeholder="--请选择--" ltype="combobox"  ligerui="width: 200">
							</div>
						</div>
					</div>
					
					<div class="clearFix"></div>
					
					<!-- 表单按钮 -->
					<div class="btnsBox formBtns notRight">
						<span id="searchBtn" class="sq-button-round">查询</span>
						<span id="clearBtn" class="sq-button-round">清空</span>
						<input id="resetBtn" type="reset" value="重置" class="l-button l-button-reset Hide"/>
						<span id="addBtn" class="sq-button-round" onclick="save('','add');">新增</span>
		            </div>
		            
				</div>
			</form>
			<!-- 搜索表单结束 -->
		</div>
		<!-- 列表显示块 -->
		<div id="ligergrid1" class="sq-grid"></div>
	</div>
	
</div>
</div>
</div>
<script type="text/javascript">
	var pageInApp={
		flag:false //tab页验证关闭
	};//to下一级子窗口 接口
	var pageInTab=null;//页签
	var loadedTabs=[];//页签
	var grid = null;
	
	$(function () {
		
		  //结清类型
		  $("#settleTypeList").ligerComboBox({ 
				url: '<%=path%>/archive/arcReceiptMain/settleTypeList.do',
				ajaxType :'GET',
		        slide: false,
		        selectBoxHeight: 200,
		        valueField: 'key', 
		        textField: 'value',
		        isMultiSelect: true
		    });
		  
		$("#searchBar").ligerForm();//初始化表单
		
	    initGrid();//初始化列表
	    searchBtnEvent();//查询按钮事件
	    clearBtnEvent();//清空按钮事件
	    
	  
	    
	});
	
	
	//查询参数
	function getSearchParams(){
		var form = new liger.get("searchBar");
		var data = form.getData();
		return data;
	}
	
	//初始化列表
	function initGrid(){
		$("#ligergrid1").ligerGrid({
			url:'<%=path%>/archive/arcReceiptMain/initList.do',
			method:'get',
			parms:getSearchParams(),
			columns:[
				{ display: '交接单名称', 
						render:function (rowdata, rowindex, value){
							return "<span title="+rowdata.listName+">"+rowdata.listName+"</span>";
						}
				},
				{ display: '承租人类型', name: 'lesseeType'},
				{ display: '事业部', 
					render:function (rowdata, rowindex, value){
						if(!rowdata.buOrgCd) return "";
						return "<span title="+rowdata.buOrgCd+">"+rowdata.buOrgCd+"</span>";
					}
				},
				{ display: '业务类型', 
					render:function (rowdata, rowindex, value){
						if(!rowdata.prjBizType) return "";
						return "<span title="+rowdata.prjBizType+">"+rowdata.prjBizType+"</span>";
					}
				},
				{ display: '担保人', name: 'guarantee'},
				{ display: '担保人类型', name: 'guaranteeType'},
				{ display: '结清类型', 
					render:function (rowdata, rowindex, value){
						if(!rowdata.settleType) return "";
						return "<span title="+rowdata.settleType+">"+rowdata.settleType+"</span>";
					}
				},
				{ display: '当前版本', name: 'version'},
				{
					display:'操作',width:250,
					render:function (rowdata, rowindex, value){
						var h="";
							h+='<a class="sq-button-hasicon" href="javascript:historicalVersion(';
			                h+="'"+rowdata.id+"'";
			                h+=")\"><i class='sqBtnIco_4'></i>历史版本</a>";
		                
			                h+='<a class="sq-button-hasicon" href="javascript:save(';
			                h+="'"+rowdata.id+"',";
			                h+="'view'";
			                h+=")\"><i class='sqBtnIco_1'></i>查看</a>";
			                
			            	h+='<a class="sq-button-hasicon" href="javascript:save(';
			                h+="'"+rowdata.id+"',";
			                h+="'update'";
			                h+=")\"><i class='sqBtnIco_4'></i>修改</a>";
						
			                h+='<a class="sq-button-hasicon" href="javascript:removeById(';
			                h+="'"+rowdata.id+"',";
			                h+="'"+rowdata.listName+"'";
			                h+=")\"><i class='sqBtnIco_7'></i>删除</a>";
			                
						return h;
					}
				}
			],
			pageSize:10,
			root:'rows',
			record:'total',
			hideLoadButton:false,
			width:'100%',
			height:'100%',
			heightDiff:-2,
			//checkbox:true,//列表是否有选择框
			rownumbers:true,//列表是否有行号
			//选择行事件
			onSelectRow: function(rowdata, rowid, rowobj){
				
			},
			//取消选择行事件
			onUnSelectRow : function(rowdata, rowid, rowobj){
				
			}
		});
		grid = liger.get("ligergrid1");
		grid.setHeight(100);
		//grid.options.isSingleCheck = true;//列表是否为单选
	}
	
	
	
	//清空按钮事件
	function clearBtnEvent(){
		$("#clearBtn").click(function(event) {
			$("#resetBtn").click();  //重置 input-text
			var form = liger.get("searchBar");
			form.setData({  //重置表单
				"buOrgCd":"",
				//"settleTypeList":""
			});
			
			liger.get('settleTypeList').clear();//重置多选select

		});
	}
	
	//查询按钮事件
	function searchBtnEvent(){
		$("#searchBtn").click(function(event) {
			var form = new liger.get("searchBar");
			var data = form.getData();
			//alert(JSON.stringify(data));
			for (name in data){
				grid.setParm(name,data[name]);
			};
			grid.reload();
		});
	}

	//新增和修改
	function save(id,operate) {
		var title;
		if(operate == "add") {
			title ="新增";
		}else if(operate == "update") {
			title ="修改";
		}else {
			title ="查看";
		}
		Add_navTab("arcReceiptMain"+id+operate, "交接单"+title, '<%=path%>/archive/arcReceiptMain/toSave.do?id='+id+'&operate='+operate , function () {
			grid.reload();
		});
	}
	
	//历史版本
	function historicalVersion(id) {
		
		 $.ligerDialog.SQopen({
            cls: 'noBorder_Dialog',
            width: 800,
            height:500,
            title : '历史版本',
            url:'<%=path%>/archive/arcReceiptMain/historicalVersion.do?id='+id,
           /*   buttons: [{
                text: "取消", type: 'cancel', cls: 'l-dialog-btn-no', 
	                onclick: function (item, Dialog) {
	                	alert("$.ligerDialog.SQopen--onclick");
	                    //在子页面里绑定 frameElement.dialog.onCancel = function () {}
	                    if (Dialog.onCancel2) {
	                    	Dialog.onCancel2();
	                    	alert("$.ligerDialog.SQopen--onclick--Dialog.onCancel");
	                    	Dialog.close(); 
	                    }
	                }
	            }
	        ],
            onClose: function () {
            	alert("onClose");
            } */
        });
		
	}
	
	
	//删除
	function removeById(id,tip) {
		$.ligerDialog.confirm('确定删除 '+tip+' 吗?', function (flag) {
			if(flag == false)return;
			var wait_dialog;
			$.ajax({
				type: 'get',
				dataType:'json',
				url: '<%=path%>/archive/arcReceiptMain/removeById.do?id='+id,
				beforeSend: function(){
			          wait_dialog=$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING ,SQ_type: "waitting"});
			     },
				success:function(msg){
					wait_dialog.close();
					 if(msg.success == 1){
						 $.ligerDialog.SQalert({content:msg.info, SQ_type: "success"});
						 grid.reload();
					 }else{
						 $.ligerDialog.SQalert({content:msg.info, SQ_type: "error"});
					 }
				}
			});
		});
	}
	
	//刷新列表
	function reloadList(){
		//location.reload();
		grid.reload();
	}
	
</script>
</body>
</html>